package io.gitee.zicai.task.controller

import io.gitee.zicai.task.job.JobService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

/**
 * JobController
 * @author zicai
 * @since 2020-05-27
 */
@RestController
@RequestMapping("/job")
open class JobController {

    @Autowired
    private lateinit var jobService: JobService

    @GetMapping("/start/{jobName}")
    fun add(@PathVariable("jobName") jobName: String) {
        jobService.start(jobName)
    }

    @GetMapping("/remove/{jobName}")
    fun remove(@PathVariable("jobName") jobName: String) {
        jobService.remove(jobName)
    }
}